Xbasic

mrec_eof Function

Syntax

L MREC_EOF([g group])

Arguments

group

g

Description

Returns true if object is at end of the group.

Discussion

The mrec_eof() function is useful if you want to put some conditional text in the header, detail or footer of the last group in a parent group. The mrec_eof() function takes a group name as an argument and returns .t. or .f. depending on whether the you are in the last group within a series of groups. Consider a report that has two levels of grouping. The top-most group is State and the inner group is City. For a given state, there will be multiple city groups. For example, NY might have groups for Albany, Buffalo and New York City. E.g.

New York
    Albany
    Buffalo
    New York City

When the 'Albany' group is printing, the following function will return .f.

mrec_eof(grp->city)

When the 'Buffalo' group is printing, the function will also return .f.. But, when the 'New York City' group is printing, the function will return .t. because 'New York City' is the last group within the parent group ('State'). Assume further that the states in the report are:

New York
Oregon
Washington

When the New York and Oregon groups are printing, the following expression will return .f. because both New York and Oregon are not the last groups in the list of states.

mrec_eof(grp->state)

However, when the Washington group is printing, the function will return .t. because Washington is the last group in the list of states. Say you wanted to put some text in the group footer for the City group, but only if you were printing the group footer for the last group in a given state. To do this you would define a calculated field that referenced mrec_eof(grp->state). For example:

calc1 = if(mrec_eof(grp->city), "Last city in state","More cities...")

Similarly, you might define another calc field:

calc2 = if(mrec_eof(grp->state), "Last state","More states...")

For example

NY
    Albany
    Group footer for Albany - calc1 = "More cities..."
    Buffalo
    Group footer for Buffalo - calc1 = "More cities..."
    New York City
    Group footer for New York City - calc1 = "Last city in state"
Group footer for NY - calc2 = "More states..."
....
Washington
    Olympia
    Group footer for Olympia - calc1 = "More cities..."
    Seattle
    Group footer for Seattle - calc1 = "Last city in state"
Group footer for Washington - calc2 = "Last state"